package com.qiku.controller;

import com.qiku.Student;
import com.qiku.feign.StudentFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@RestController
@RequestMapping("/page")
public class PageController {



    @Autowired
    private StudentFeign studentFeign;


    @GetMapping("/port")
    public String getPort(){
        return studentFeign.getPort();
    }


    @GetMapping("/queryFeign")
    public List<Student> query(){
        return studentFeign.findAll();
    }



    @RequestMapping("/findById/{id}")
    public Student findById(@PathVariable Integer id){
        Student student = studentFeign.findById(id);
        return student;
    }


    @PostMapping("/add")
    public void addstu(@RequestBody Student student){
        studentFeign.addstu(student);


    }


    @RequestMapping("/update")
    public void UpdateStu(Student student){
        student.setId(5);
        student.setName("邓士载");
        student.setAge(17);
        student.setHome("义阳郡棘阳");
        studentFeign.UpdateStu(student);

    }





    @RequestMapping("/delete/{id}")
    public void deleteStu(@PathVariable Integer id){
        studentFeign.deleteStu(id);

    }








}
